/**
 * 表结构初始化
 */

const { Sequelize, Model, DataTypes } = require('sequelize')
const { sequelize } = require('@core/db.js')

/**
 * 分类表
 */
const Category = sequelize.define('Category', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  name: DataTypes.STRING
});


/**
 * 商品表
 */
const Goods = sequelize.define('Goods', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  title: DataTypes.STRING,
  categoryId: DataTypes.INTEGER
});

// Goods.belongsTo(Category, { foreignKey: 'category_id' })

module.exports = {
  Goods,
  Category
}